<%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 2020/8/27
  Time: 14:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%String path = request.getContextPath();%>
<script src="<%=path%>/static/js/jquery-1.8.3.js"></script>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>i学习</title>
    <link rel="stylesheet" href="<%=path%>/static/css/index.css">
    <link rel="stylesheet" href="<%=path%>/static/css/homeindex.css">
    <link rel="stylesheet" href="<%=path%>/static/css/home.css">
    <link rel="stylesheet" href="<%=path%>/static/css/base.css">
    <link rel="stylesheet" href="<%=path%>/static/css/watch.css">
    <script src="<%=path%>/static/js/head.js"></script>
</head>
<body>
<div id="vue_body">

    <!-- 顶部   -->
    <div class="header">
        <div class="width_1200 clearfix">
            <div class="header_right right_f">
                你好
                <div class="item uname" v-if="user"><c:if test="${sessionScope.user==null}"><a href="login.jsp">请登录</a></c:if>
                    <c:if test="${sessionScope.user!=null}"><a href="homePage.jsp">,${sessionScope.user.userName}!</a></c:if></div>
                <div class="item">欢迎来到i学习！</div>
                <div class="item" ><a href="registration.jsp">[注册]</a></div>
                <div class="item" onclick="exitLogin()">退出</div>
                <div class="item service">客服中心</div>
            </div>

        </div>
    </div>

</div>
<!-- 内容   -->
<div class="logobox width_1200" style="margin-left: 10%">
    <div class="logo left_f">
        <a href="<%=path%>/index?action=getshowlist"><img src="<%=path%>/static/img/logo.jpeg" width="60" height="120"></a>
    </div>
    <div class="searchbox left_f">
        <div class="input clearfix">
            <form action="<%=path%>/index?action=getlistbyname" method="post">
                <input type="text"  style="width: 418px;font-size: 16px" name="videoname" placeholder="请输入关键词">
                <span><input style="margin-left: 66px; text-index:0px;width: 110px;font-size: 22px;border:#000000 2px solid" type="submit" value="站内搜索"></span>
            </form>
        </div>

    </div>

    <a class="myclass left_f" rel="nofollow"
       href="<%=path%>/uploadServlet?action=going" onclick="return uploadex()"> <span class="icons"></span>我要上传</a>

</div>
</div>

<hr style="width:100%;height:3px;">
<div>
<div class="i_bg bg_color">
    <div class="m_content">
        <div class="m_left">
            <div class="left_n">管理中心</div>
            <div class="left_m">
                <div class="left_m_t t_bg1"><a href="<%=path%>/userServlet?action=personInfo">个人中心</a></div>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg2"><a href="<%=path%>/Comment?action=getCommentByUser&currentPage=1">我的评论</a>
                </div>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg3"><a href="<%=path%>/Watch?action=getWatchlist&currentPage=1">观看历史</a></div>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg1"><a href="<%=path%>/uploadServlet?action=going">我要上传</a></div>
            </div>
            <c:if test="${sessionScope.user.userType>2}">
            <div class="left_m">
                <div class="left_m_t t_bg4"><a href="<%=path%>/userServlet?action=userManage">用户管理</a></div>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg5"><a href="<%=path%>/uploadServlet?action=getList&currentPage=1">视频审核</a></div>
            </div>
            </c:if>
        </div>

    <div class="m_right">
        <div class="m_des">
            <table border="0" style="width:800px; line-height:22px;" cellspacing="0" cellpadding="0">
                <tr valign="top">
                    <td>资源名称</td><td>观看时间</td><td style="width: 8%">操作</td></tr>
            <c:forEach items="${requestScope.watchList}" var="watch" >
                <tr class="td">
                <td>${watch.videoName}</td>
                <td>${watch.watchTime}</td>
                <td style="width: 8%"><input type="button" value="删除" onclick="del(${watch.id})" ></td>
                </tr>
            </c:forEach>

            </table>
        </div>
        <div class="pages" style="float: right;text-align: right; margin-right: 10%">
            <c:choose>
                <c:when test="${page.pageCount <= 5}">
                    <c:set var="begin" value="1"/>
                    <c:set var="end" value="${page.pageCount}"/>
                </c:when>
                <%--页数超过了6页--%>
                <c:otherwise>
                    <c:set var="begin" value="${page.pageNo-1}"/>
                    <c:set var="end" value="${page.pageNo+2}"/>
                    <%--如果begin减1后为0,设置起始页为1,最大页为6--%>
                    <c:if test="${begin -1 <= 0}">
                        <c:set var="begin" value="1"/>
                        <c:set var="end" value="4"/>
                    </c:if>
                    <%--如果end超过最大页,设置起始页=最大页-5--%>
                    <c:if test="${end > page.pageCount}">
                        <c:set var="begin" value="${page.pageCount - 3}"/>
                        <c:set var="end" value="${page.pageCount}"/>
                    </c:if>
                </c:otherwise>
            </c:choose>
            <a style="margin-left: 8px;font-size: 26px" href="<%=path%>/Watch?action=getWatchlist&currentPage=1" class="p_pre">首页</a>
            <c:if test="${page.pageNo>0}">
                <a style="margin-left: 8px;font-size: 26px" href="<%=path%>/Watch?action=getWatchlist&?currentPage=${page.pageNo-1}" class="p_pre">上一页</a>
            </c:if>
            <c:forEach var="i" begin="${begin}" end="${end}">
                <%--当前页,选中--%>
                <a style="margin-left: 8px;font-size: 26px" href="<%=path%>/Watch?action=getWatchlist&currentPage=${i}" <c:if test="${(page.pageNo)==i}">style="background-color:antiquewhite"</c:if>>${i}</a>
            </c:forEach>
            <c:if test="${page.pageNo<(page.pageCount-1)}">
                <a style="margin-left: 8px;font-size: 26px" href="<%=path%>/Watch?action=getWatchlist&currentPage=${page.pageNo+1}" class="p_pre">下一页</a>
            </c:if>
            <a style="margin-left: 8px;font-size: 26px" href="<%=path%>/Watch?action=getWatchlist&currentPage=${page.pageCount}" class="p_pre">尾页</a>
        </div>
    </div>
</div>
<div class="btmbg">
    <div class="btm">
        <div >
            <div>
                <span>关于我们</span>
                <span>联系我们</span>
                <span>诚聘英才</span>
                <span>商务合作</span>
                <span>常见问题</span>
            </div>
            <div>
                <a href="//beian.miit.gov.cn/" rel="nofollow">备案许可号：赣ICP备08666666号</a>
                <a target="_blank" >赣公网安备 0000000000000000号</a>
                <span>出版经营许可证</span>
            </div>
            <div>
                <span>运营公司：江西i学习教育咨询有限公司</span>
                <span>法律顾问：张律师</span>
            </div>
            <div>
                Ixuexi,All Rights Reserved.版权所有 i学习
            </div>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    function del(id) {
        $.ajax({
            url: "/Watch",
            data:{
                action:"delWatch",
                id:id
            },
            method: "POST",
            dataType: "json",
            success: function (result) {
                if(result.status === 1){
                    alert(result.message);
                    window.location.reload();;
                }
            }
        });
    }
</script>
</body>
</html>
